﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<MyMainSite.Models.BaseModel>" %>

<h2>Blogs</h2>

<ul>
    <% foreach (var b in Model.Blogs)
       {
           if (Model.CurrentBlog != null && Model.CurrentBlog.Name == b.Name)
           {
               %><li><%= b.Name%> - (<%=b.BlogEntries.Count%>)</li><%
           }
           else
           {
               %><li><a href="/blog/index/<%= b.FriendlyUrl %>"><%= b.Name%> - (<%=b.BlogEntries.Count%>)</a></li><%
           }
       } %>

</ul>

<h2>Projects</h2>

<ul>
    <% foreach (var p in Model.Projects)
       {
           if (Model.CurrentController.ToLower().Trim() == "projects" && p.FriendlyUrl.ToLower().Trim() == Model.CurrentProject.ToLower().Trim())
           {
               %><li><%= p.Name%> - (<%: Model.ProjectBlogEntryCount[p.ProjectId] %>)</li><%
           }
           else
           {
               %><li><a href="/projects/index/<%= p.FriendlyUrl %>"><%= p.Name%> - (<%: Model.ProjectBlogEntryCount[p.ProjectId] %>)</a></li><%
           }
       } %>

</ul>

<h2>History</h2>

<ul>
    <% var startDate = new DateTime(Model.MinimumBlogYear, 1, 1);
       var loopDate = DateTime.Now;

       while (loopDate > startDate)
       {
           if (loopDate.Year == Model.CurrentYear && Model.CurrentMonth == 0)
           {
               %><li><%: loopDate.Year%><%
           }
           else
           {
               %><li><a href="/blog/date/<%: loopDate.Year %>"><%: loopDate.Year%></a><%
           }

           if (loopDate.Year != Model.CurrentYear)
           {
               loopDate = loopDate.AddMonths(-loopDate.Month); // bring to Jan of the previous year
           }
           else
           {
               %><ul><%

               while (loopDate.Year == Model.CurrentYear)
               {
                   if (Model.CurrentController.ToLower().Trim() == "blog" && loopDate.Month == Model.CurrentMonth)
                   {
                       %><li><%= System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedMonthName(loopDate.Month)%> - (<%: this.Model.DateBlogEntryCount[loopDate.ToShortDateString()] %>)</li><%
                   }
                   else
                   {
                       %><li><a href="/blog/date/<%= loopDate.Year %>/<%= loopDate.Month %>"><%= System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedMonthName(loopDate.Month)%> - (<%: this.Model.DateBlogEntryCount[loopDate.ToShortDateString()] %>)</a></li><%
                   }

                   loopDate = loopDate.AddMonths(-1);
               }

               %><li>&nbsp;</li></ul></li><%
           }
       } %>
</ul>